<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>添加权限</title>
    <link rel="stylesheet" href="/static/lib/layuiadmin/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/static/lib/layuiadmin/css/global.css" media="all">
    <link rel="stylesheet" href="/static/lib/layuiadmin/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/lib/layuiadmin/css/table.css" />
</head>

<body>
<div class="admin-main">

    <div style="margin: 15px;">
        <form class="layui-form" method="post" action="">

            <div class="layui-form-item">
                <div class="layui-input-block">
                <div style="color:red;">最终价格 = 原商品价格 x 百分比 + 增量价格</div>
                </div>
                <label class="layui-form-label">原商品价格</label>
                <div class="layui-input-inline">
                    <input type="number"   lay-verify="" id="origin" placeholder="原商品价格" autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">百分比</label>
                <div class="layui-input-inline">
                    <input type="number"   lay-verify="" id="percent" placeholder="原价的百分比" autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">在原价百分比上加价(单位：元)</label>
                <div class="layui-input-inline">
                    <input type="number"   lay-verify="" id="increment" placeholder="在原价百分比上加价" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-btn layui-btn-success" id="add-to-formula">加入到价格公式</div>
            </div>
            <div class="layui-form-item">
                <div id="formula" class="layui-input-block">

                    <{volist name="taobaoConfig.price" id="item"}>
                    <div>原价<span style="color:red;"> <{$key}> 元</span>以上的商品 采集上传后的价格是 <span style="color:red;">原价 x <{$item.percent}>% + <{$item.increment}>元</span> <span class="layui-btn layui-btn-danger layui-btn-mini delete">删除</span>
                        <input type="hidden" value="<{$key}>" name="price[origin][]"     />
                        <input type="hidden" value="<{$item.percent}>" name="price[percent][]"    />
                        <input type="hidden" value="<{$item.increment}>" name="price[increment][]"  /></div>
                    <{/volist}>
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">标题</label>
                <div class="layui-input-block">
                    <input type="text" name="title" value="<{$taobaoConfig.title}>"  placeholder="请文章标题" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">描述</label>
                <div class="layui-input-block">
                    <input type="text" name="desc"  value="<{$taobaoConfig.desc}>" placeholder="请输入文章简介" autocomplete="off" class="layui-input">
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button lay-filter="add" lay-submit class="layui-btn">提交</button>
                </div>
            </div>

        </form>
    </div>

</div>
<script type="text/javascript" src="/static/lib/layuiadmin/plugins/layui/layui.js"></script>


<script type="text/javascript">
    layui.use('form', function(){
        var form = layui.form();
    });
    layui.use(["layer","upload"],function(){
        var $ = layui.jquery;
        $("#add-to-formula").click(function(){
            var origin = $("#origin").val();
            var percent = $("#percent").val();
            var increment = $("#increment").val();
            if(!origin || !percent || !increment){
                alert("请填写完整");
                return;
            }

            $("#formula").append('<div>原价<span style="color:red;">'+origin+'元</span>以上的商品 采集上传后的价格是 <span style="color:red;">原价 x '+percent+'% + '+increment+'元</span> <span class="layui-btn layui-btn-danger layui-btn-mini delete">删除</span> \
            <input type="hidden" value="'+origin+'" name="price[origin][]"     />\
            <input type="hidden" value="'+percent+'" name="price[percent][]"    /> \
            <input type="hidden" value="'+increment+'" name="price[increment][]"  /></div>');

        });
        $("#formula").delegate(".delete","click",function(){
            $(this).parent().remove();
        })
    });

</script>

</body>

</html>